package com.singleton.pattern.singleton.demo;

/**
 *  在 某个线程中的 单例 (伪单例)
 *  并且 天生是线程安全的
 */
public class ThreadLocalSingleton {
    private static final ThreadLocal<ThreadLocalSingleton> threadLocalInstanceThreadLocal
            = new ThreadLocal<ThreadLocalSingleton>(){
        @Override
        protected ThreadLocalSingleton initialValue() {
            return new ThreadLocalSingleton();
        }
    };
    private ThreadLocalSingleton(){

    }
    public static ThreadLocalSingleton getInstance(){
        return threadLocalInstanceThreadLocal.get();
    }
}
